package com.example.assetmanagement.controller;

import com.example.assetmanagement.common.ApiResponse;
import com.example.assetmanagement.service.DashboardService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/dashboard")
@RequiredArgsConstructor
public class DashboardController {

    private final DashboardService dashboardService;

    @GetMapping("/data")
    public ApiResponse<Map<String, Object>> data() {
        return ApiResponse.success(dashboardService.getData());
    }

    @GetMapping("/asset-stats")
    public ApiResponse<List<Map<String, Object>>> assetStats() {
        return ApiResponse.success(dashboardService.getAssetStats());
    }

    @GetMapping("/maintenance-stats")
    public ApiResponse<List<Map<String, Object>>> maintenanceStats() {
        return ApiResponse.success(dashboardService.getMaintenanceStats());
    }

    @GetMapping("/trend")
    public ApiResponse<List<Map<String, Object>>> trend(@RequestParam(required = false) String start,
                                                       @RequestParam(required = false) String end) {
        return ApiResponse.success(dashboardService.getTrend(start, end));
    }
} 